package hu.bme.mit.mdsd.service.generator;

import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.generator.IFileSystemAccess;
import org.eclipse.xtext.generator.IGenerator;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.IteratorExtensions;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.StringExtensions;
import system.Platform;
import system.RestService;

@SuppressWarnings("all")
public class dotNetServiceModelGenerator implements IGenerator {
  public void doGenerate(final Resource input, final IFileSystemAccess fsa) {
    TreeIterator<EObject> _allContents = input.getAllContents();
    Iterable<EObject> _iterable = IteratorExtensions.<EObject>toIterable(_allContents);
    Iterable<system.System> _filter = IterableExtensions.<system.System>filter(_iterable, system.System.class);
    for (final system.System p : _filter) {
      Platform _targetPlatform = p.getTargetPlatform();
      boolean _operator_equals = ObjectExtensions.operator_equals(_targetPlatform, Platform.DOT_NET);
      if (_operator_equals) {
        TreeIterator<EObject> _eAllContents = p.eAllContents();
        Iterable<EObject> _iterable_1 = IteratorExtensions.<EObject>toIterable(_eAllContents);
        Iterable<RestService> _filter_1 = IterableExtensions.<RestService>filter(_iterable_1, system.RestService.class);
        for (final RestService e : _filter_1) {
          String _name = e.getName();
          String _operator_plus = StringExtensions.operator_plus(_name, ".java");
          CharSequence _compile = this.compile(e);
          fsa.generateFile(_operator_plus, _compile);
        }
      }
    }
  }
  
  public CharSequence compile(final RestService e) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("Hey Sexy PHP! :D");
    _builder.newLine();
    _builder.newLine();
    return _builder;
  }
}
